﻿using Catel.Data;
using Catel.MVVM;

namespace Catel.Articles._03___MVVM.Examples.NestedUserControls
{
    /// <summary>
    /// Bed view model.
    /// </summary>
    public class BedViewModel : ViewModelBase
    {
        #region Constructor & destructor
        /// <summary>
        /// Initializes a new instance of the <see cref="BedViewModel"/> class.
        /// </summary>
        /// <param name="bed">The bed.</param>
        public BedViewModel(Models.Bed bed)
        {
            // Store values
            Bed = bed;
        }
        #endregion

        #region Properties
        /// <summary>
        /// Gets the title of the view model.
        /// </summary>
        /// <value>The title.</value>
        public override string Title { get { return "Bed"; } }

        #region Models
        /// <summary>
        /// Gets or sets the bed.
        /// </summary>
        [Model]
        public Models.Bed Bed
        {
            get { return GetValue<Models.Bed>(BedProperty); }
            private set { SetValue(BedProperty, value); }
        }

        /// <summary>
        /// Register the Bed property so it is known in the class.
        /// </summary>
        public static readonly PropertyData BedProperty = RegisterProperty("Bed", typeof(Models.Bed));
        #endregion

        #region View model
        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        [ViewModelToModel("Bed")]
        public string Name
        {
            get { return GetValue<string>(NameProperty); }
            set { SetValue(NameProperty, value); }
        }

        /// <summary>
        /// Register the Name property so it is known in the class.
        /// </summary>
        public static readonly PropertyData NameProperty = RegisterProperty("Name", typeof(string));
        #endregion
        #endregion

        #region Commands
        #endregion

        #region Methods
        #endregion
    }
}
